package init

import (
	"flag"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"log"
	"zg5/zk1/goods-management/common/global"
	"zg5/zk1/goods-management/common/inits"
	"zg5/zk1/goods-management/common/proto/goods"
)

func init() {
	inits.GetViper()
	inits.InitNacos()
	InitGoodsGrpc()
}

func InitGoodsGrpc() {
	flag.Parse()
	// Set up a connection to the server.
	conn, err := grpc.NewClient("localhost:8899", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	global.GoodsGrpc = goods.NewGoodsSrvClient(conn)
}
